<?php
use app\assets\AppAsset;
use yii\helpers\Html;
use yii\helpers\Url;
use \yii\helpers\HtmlPurifier;
AppAsset::register($this);
$this->registerJSFile('@web/js/count.js',['depends'=>['app\assets\AppAsset']]);
?>
<form action="?r=writing/index" id="nextque" method="post">
	<input type="hidden" name="page" value="<?=$page;?>">
	<input name="_csrf" type="hidden" id="_csrf" value="<?= Yii::$app->request->csrfToken;?>">
	<input name="usercheck" type="hidden" value="">
	<input type="hidden" name="post_type" value="">
	<input type="hidden" name="composition" value="">
</form>
<script>
	window.onload = function () {

		<?php
		$session = \Yii::$app->session;
		$session->open();
		$session['form']=2;/*2.php存作文，判断是1.php还是3.php的第一方面，第二方面···*/
		?>
		var $submit_time=$("[name=post_type]").clone(true).attr("name","time");
		$submit_time.appendTo("#nextque");
		var t=0;
		$.ajax({
			url: "?r=ajax/gettime&state=<?=$state;?>&token=<?=$token;?>",
			dataType: 'json',
			type: 'get',
			success: function (data) {
				var $time=$("i.fa-clock-o");
				var sec=data.time;          //初始时间，以秒为单位
				setInterval(
					function(){
						sec++;
						t++;
						$time.html(secToMin(sec));
						$submit_time.val(t);
					},1000);
			}
		});
		
		$("#next").click(function(){
			$("[name=composition]").val($("#compositionx").html());
			$("#nextque").submit();
		})

        var timeCount=new countTime({
            parent:"time-count",
            alert:"已经30分钟了哦",
            count:1800,
            css:{
                "margin-left":"150px"
            }
        });
        timeCount.init();

	};
</script>
<div class="container">
	<div class="leadx row clearfix">
		<div class="col-xs-3 pull-left">
			<span>
				TPO<?=$write_content['class_num'];?> Writing <?=$write_content['class_name']?>
			</span>
		</div>
		<div class="col-xs-1 pull-left notebook">
			<a href="#"><span><i class="fa fa-pencil-square-o"></i> 笔记</span></a>
		</div>
		<div class="col-xs-1 pull-right">
			<span><i class="fa fa-clock-o"></i></span>
		</div>
	</div>
	<div class="write-wrap clearfix">
		<div class="write-info row"></div>
		<div class="col-xs-5 write-spe">
			<div class="write-que-lead">
				<p>
					Directions:You have 30 minutes to plan and write your response.Yourresponse will be judged on the basis of the quality of your writing and on how well your response presents the points in the lecture and their relationship to the reading passage.Typically an effective response will be 300 words at least.
				</p>
			</div>
			<br>
			<div class="write-que">
				<p>Question:</p>
				<p class="write-que-qt">
					<?=$write_content['question'];?>
				</p>
			</div>
		</div>
		<div class="col-xs-7 write-text write-text-ano">
			<div class="write-chart clearfix">
				<div class="mychart pull-left">
					<i class="fa fa-wpforms"></i>&nbsp;&nbsp;<span>我的结构图</span><span id="icon"><i class="fa fa-arrow-down"></i></span>
				</div>
                <div id="time-count" class="pull-left">0000</div>
				<div class="word-count pull-right">Word count: <span></span></div>
			</div>
			<div class="writing">
				<div id="compositionx" contenteditable="true"></div>
			</div>
		</div>
	</div>
</div>
<div class="chart">
	<?php
	$session = \Yii::$app->session;
	$session->open();
	if($write_content['class_name']=='综合写作') {
		?>
		<div class="closeit">
			<span id="close"><i class="fa fa-times"></i></span>
		</div>
		<div class="chart-one">
			<div class="totalviews"><span class="view-lead">总观点</span><span><?=HtmlPurifier::process($session['total_views3']);?></span>
			</div>
			<div class="firstview"><span class="view-lead">第一方面</span><span><?= HtmlPurifier::process($session['first_view3']); ?></span></div>
			<div class="secondview"><span class="view-lead">第二方面</span><span><?= HtmlPurifier::process($session['second_view3']); ?></span>
			</div>
			<div class="thirdview"><span class="view-lead">第三方面</span><span><?= HtmlPurifier::process($session['third_view3']); ?></span></div>
		</div>
		<div class="chart-two">
			<div class="totalviews"><span class="view-lead">总观点</span><span><?= HtmlPurifier::process($session['total_views1']); ?></span></div>
			<div class="firstview"><span class="view-lead">第一方面</span><span><?= HtmlPurifier::process($session['first_view1']); ?></span></div>
			<div class="secondview"><span class="view-lead">第二方面</span><span><?= HtmlPurifier::process($session['second_view1']); ?></span>
			</div>
			<div class="thirdview"><span class="view-lead">第三方面</span><span><?= HtmlPurifier::process($session['third_view1']); ?></span></div>
		</div>
		<?php
	}
	elseif($write_content['class_name']=='独立写作') {
		?>
		<div class="closeit">
			<span id="close"><i class="fa fa-times"></i></span>
		</div>
		<div class="chart-one">
			<div class="totalviews"><span class="view-lead">总观点</span><span><?= HtmlPurifier::process($session['total_views3']); ?></span>
			</div>
			<div class="firstview"><span class="view-lead">第一方面</span><span><?= HtmlPurifier::process($session['first_view3']); ?></span></div>
			<div class="secondview"><span class="view-lead">第二方面</span><span><?= HtmlPurifier::process($session['second_view3']); ?></span>
			</div>
			<div class="thirdview"><span class="view-lead">第三方面</span><span><?= HtmlPurifier::process($session['third_view3']); ?></span></div>
		</div>
		<?php
	}
	?>
</div>
<div class="addnote">
    <div class="note-lead">
        <span id="note-word">笔记</span>
        <span class="close"><i class="fa fa-times"></i></span>
    </div>
    <div class="note-text">
        <div contenteditable="true" id="note-self"><?=HtmlPurifier::process($my_note['note']);?></div>
    </div>
    <form action="#" id="note-form">
        <button type="button" name="note-save" id="note-submit">Save and Close</button>
        <input type="hidden" name="saved-note" value="">
    </form>
</div>